import math
import cached_math
import time


def _benchmark():
    print("BENCHMARK:")

    starting = time.perf_counter()
    for _ in range(0, 100):
        for i in range(0, 1000):
            math.factorial(i)
    ending = time.perf_counter()
    delta = ending - starting
    print(f"{'math.factorial':30s}: {delta:10.2f}")

    starting = time.perf_counter()
    m = cached_math.CachedMath()
    for _ in range(0, 100):
        for i in range(0, 1000):
            m.factorial_slow(i)
    ending = time.perf_counter()
    delta = ending - starting
    print(f"{'CachedMath.factorial_slow':30s}: {delta:10.2f}")


if __name__ == '__main__':
    _benchmark()
